package cn.mason.echarts;

import com.baomidou.kisso.SSOHelper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.client.RestTemplate;

import javax.servlet.http.HttpServletRequest;

@SpringBootApplication
@Controller
public class EchartsApplication {

	@RequestMapping("/index")
	public String index(HttpServletRequest request){
		String id = SSOHelper.getSSOToken(request).getId();
		if(id==null||"".equals(id)){
			return "login";
		}else{
			return "index";
		}
	}

	@RequestMapping("/3D-scatter")
	public String scatter3D(){
		return "3D-scatter";
	}

	@RequestMapping("/2D-scatter")
	public String scatter2D(){
		return "2D-scatter";
	}

	@RequestMapping("/pie")
	public String pie(){
		return "pie";
	}

	@RequestMapping("/graph")
	public String graph(){
		return "graph";
	}

	@RequestMapping("/line")
	public String line(){
		return "line";
	}

	@RequestMapping("/bar")
	public String bar(){
		return "bar";
	}

	@Bean
	@LoadBalanced
	RestTemplate restTemplate() {
		return new RestTemplate();
	}


	public static void main(String[] args) {
		SpringApplication.run(EchartsApplication.class, args);
	}
}
